package learn.decorator;

/**
 * 装饰器模式
 *
 * @author 执笔
 * @date 2019/12/26 16:16
 */
public class Decorator {


    /**
     * 组件接口
     */
    interface Component {
        void draw();
    }

    /**
     * 基础组件
     */
    class Text implements Component {

        public void draw() {
            //
        }
    }

    /**
     * 装饰器
     */
    abstract class DecoratorComponent implements Component{
        protected Component component;

        public DecoratorComponent(Component component){
            this.component = component;
        }

        public void draw(){
            component.draw();
        }
    }

    /**
     * 富文本组件
     */
    class FullText extends DecoratorComponent{

        public FullText(Component component) {
            super(component);
        }

        @Override
        public void draw()
        {
            this.setFull();
            super.draw();
        }

        public  void setFull()
        {
            //
        }
    }

}
